<?php
namespace app\controller;

use app\BaseController;
use think\facade\View;
use think\facade\Db;
use think\facade\Request;

class Wxindex extends BaseController
{
    public function wxindex()
    {
        $list = Db::table('okr_users')->select();
        $data = $list->toArray();
        $minlist = Db::table('shop_goods')->select();
        $data2=$minlist->toArray();
    
        if(Request::method() == "GET")
            {       
                echo json_encode(['mindisp'=>$data2,'msg'=>'小程序所需okr']);
                exit();
            
            }

    }

    public function wxadd()
    {
        if(Request::method()=="POST"){
            $all=Request::param();
            $insert = Db::table('shop_goods')->insert($all);
            if($insert){
                echo json_encode(['code'=>200,'msg'=>'添加成功']);
            }
            else{
                echo json_encode(['code'=>1,'msg'=>'添加失败']);
            }
        }
    }

    public function login()
    {
        return '这是Wxindex登录方法';
    }

}
